#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=1e6+5,V=1e6,INF=1e8;
int n;
int mn[N*4],mx[N*4],F[N*4];
multiset<int>SL,SR,FL[N],FR[N];
inline void build(int p,int l,int r){
	mn[p]=V+1,mx[p]=0,F[p]=INF;
	if(l==r)return;
	const int mid=(l+r)>>1,ls=p*2,rs=p*2+1;
	build(ls,l,mid),build(rs,mid+1,r);
}
inline void upd(int p,int l,int r,int x){
	if(l==r){
		if(FL[l].empty())mn[p]=V+1;
		else mn[p]=*FL[l].begin();
		if(FR[r].empty())mx[p]=0;
		else mx[p]=*prev(FR[r].end());
		F[p]=INF;
		return;
	}
	const int mid=(l+r)>>1,ls=p*2,rs=p*2+1;
	x<=mid?upd(ls,l,mid,x):upd(rs,mid+1,r,x);
	mn[p]=min(mn[ls],mn[rs]),mx[p]=max(mx[ls],mx[rs]),F[p]=min(F[ls],F[rs]);
	if(1<=mx[ls]&&mn[rs]<=V)F[p]=min(F[p],mn[rs]-mx[ls]+1);
}
inline bool check(pair<int,int>x){
	return FL[x.first].count(x.second);
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    freopen("stone.in","r",stdin);
    freopen("stone.out","w",stdout);
	cin>>n;
	build(1,1,V);
	for(int i=1;i<=n;++i){
		char o;int l,r;cin>>o>>l>>r,--r;
		if(o=='A'){
			SL.emplace(l),SR.emplace(r);
			FL[l].emplace(r),FR[r].emplace(l);
			upd(1,1,V,l),upd(1,1,V,r);
		}
		else{
			SL.erase(SL.find(l)),SR.erase(SR.find(r));
			FL[l].erase(FL[l].find(r)),FR[r].erase(FR[r].find(l));
			upd(1,1,V,l),upd(1,1,V,r);
		}
		if((*prev(SL.end()))<=(*SR.begin())){
			cout<<(*FL[*prev(SL.end())].begin())-(*prev(FR[*SR.begin()].end()))+1<<'\n';
		}
		else{
			cout<<F[1]<<'\n';
		}
	}
	return 0;
}
/*
*/